var btn = document.querySelector("button");
btn.addEventListener("click", function() {
  var inputA = document.querySelector("#a");
  var inputB = document.querySelector("#b");
  if (inputA.value.trim() == "") {
    return;
  }
  if (inputB.value.trim() == "") {
    return;
  }
  var aVal = parseInt(inputA.value);
  var bVal = parseInt(inputB.value);
  /*
  <select id="op">
    <option value="+">+</option>
    <option value="-">-</option>
    <option value="*">*</option>
    <option value="/">/</option>
  </select>
   */
  var op = document.querySelector("#op");
  var index = op.options.selectedIndex;
  var option = op.options[index];
  var resultVal;
  switch (option.value) {
    case "+": resultVal = aVal + bVal; break;
    case "-": resultVal = aVal - bVal; break;
    case "*": resultVal = aVal * bVal; break;
    case "/": resultVal = aVal / bVal; break;
  }

  var spanResult = document.querySelector("#result");
  spanResult.innerText = resultVal;
});